﻿using System;
using System.Data;
using System.Collections.Generic;
using He.Model;
namespace He.BLL
{
    /// <summary>
    /// PicturesExtension
    /// </summary>
    public partial class attr_value
    {
        #region  Method

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool ExistsByFieldId(int fieldId)
        {
            return dal.ExistsByFieldId(fieldId);
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool ExistsByAttrItemId(int attrItemId)
        {
            return dal.ExistsByAttrItemId(attrItemId);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public He.Model.attr_value GetModel(string strWhere)
        {
            return dal.GetModel(strWhere);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteByPid(int id)
        {

            return dal.DeleteByPid(id);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteByFid(int id)
        {
            return dal.DeleteByFid(id);
        }

        /// <summary>
        /// 增加多条数据
        /// </summary>
        public void AddModelList(List<Model.attr_value> ModelList)
        {
            if (ModelList != null)
            {
                foreach (Model.attr_value item in ModelList)
                {
                    dal.Add(item);
                }
            }
        }
        /// <summary>
        /// 修改多条数据
        /// </summary>
        public void UpdateModelList(List<Model.attr_value> ModelList)
        {
            if (ModelList != null)
            {
                foreach (Model.attr_value item in ModelList)
                {
                    if (dal.ExistsByPFId(item.picture_id, item.field_id))
                    {
                        dal.UpdateByPFId(item);
                    }
                    else
                    {
                        dal.Add(item);
                    }
                }
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        /// <summary>
        /// 获得产品列表的扩展字段值
        /// </summary>
        public List<Model.attr_value> GetAttrValueListByPictureIds(List<int> idList)
        {
            DataSet ds = dal.GetAttrValueListByPictureIds(idList);
            return DataTableToList(ds.Tables[0]);
        }

        #endregion  Method
    }
}

